<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
		.father{
			width: 300px;
			height: 300px;
			background-color: pink;
			position: relative;
			

		}
		.son{
			width: 70px;
			height: 70px;
			background-color: blueviolet;
			position: absolute;
			top: 25px;
			left: 25px;
			margin: 20px;

		}
	</style>
</head>
<body>
	<div class="father">
		<div class="son">
			
		</div>
	</div>
	<script type="text/javascript">
		var son = document.querySelector('.son')

		// 偏移量
		console.log("对于左侧的偏移量", son.offsetLeft)
		console.log("对于顶部的偏移量", son.offsetTop)
		// 在不脱标的情况下  offsetLeft/offsetTop 取决于父元素的margin, padding,border   和子元素的margin, padding,border 

		// 在脱标的情况下  之却决于
	</script>
</body>
</html>